// pages/ucenter/index/index.js
import { checkLogin } from '../../../utils/util.js';

const app = getApp();
var random = Math.random();
Page({
    data: {
        navH: 0,
        userInfo: [],
    },

    onLoad: function (options) {
        var that = this;
        let navH = app.globalData.navHeight;
        /*顶部导航高度*/
        that.setData({
            navH: navH
        });
    },
    
    onShow: function () {
        /*判断是否登录*/
        let userInfo = checkLogin();
        console.log('userInfo：');
        console.log(userInfo);
        this.setData({
            userInfo: userInfo
        });
    },

    //退出登录
    exitLogin: function () {
        wx.showModal({
            title: '',
            confirmColor: '#1a1a1a',
            content: '退出登录？',
            success: function (res) {
                if (res.confirm) {
                    wx.removeStorageSync('token');
                    wx.removeStorageSync('userInfo');
                    wx.navigateTo({
                        url: '/pages/login/login'
                    });
                }
            }
        })
    },

    goto_setting: function(){
        wx.navigateTo({
            url: '/pages/ucenter/setting/setting'
        }); 
    }
})